{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# This script obtaining frames from camera and save as jpg."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "\n",
    "import cv2\n",
    "video_capture = cv2.VideoCapture(0)\n",
    "c=0\n",
    "while True:\n",
    "    # Capture frame-by-frame\n",
    "\n",
    "    ret, frame = video_capture.read()\n",
    "\n",
    "    \n",
    "    timeF = 10\n",
    "    \n",
    "    if(c%timeF == 0): #save as jpg every 10 frame  \n",
    "         cv2.imwrite('~/train_dir/me'+str(c) + '.jpg',frame) #save as jpg\n",
    "\n",
    "    c+=1\n",
    "   \n",
    "\n",
    "    if cv2.waitKey(1) & 0xFF == ord('q'):\n",
    "        break\n",
    "\n",
    "# When everything is done, release the capture\n",
    "\n",
    "video_capture.release()\n",
    "cv2.destroyAllWindows()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
